<?php

namespace admin\controller;

use admin\model\ReplyModel;
use admin\model\upload;

class ReplyController extends Controller{

    private $reply;

    public function __construct(){
        $this->reply = new ReplyModel();
    }
    /**
     * 修改留言信息
     */
    public function editReply($params){
        return $this->reply->updateReply($params);
    }
    //查询所有的信息以 JSON 形式返回
    public function getReplysJson($params){
        $data = $this->reply->getReplyAll($params);
        $count_data = $this->reply->getReplyCount(array('content'=>$params['content']));
        $data_json = [];
        $data_json['code'] = 0;
        $data_json['msg'] = '';
        $data_json['count'] = $count_data['count'];
        $data_json['data'] = $data;
        return json_encode($data_json);
    }
    //显示评论界面
    public function getReplyAll(){
        return $this->view('manageReply');
    }
    /**
     * 设置评论不可见
     */
    public function setReplyHide($params){
        $data = $this->reply->hideReply($params);  //操作数据库并返回状态嘛
        return json_encode($data);      //返回给前端 ajax 
    }
    /**
     * 删除追评
     */
    public function delReply($params){
        $data = $this->reply->delReply($params);  
        return json_encode($data);    
    }
}